Plots of the three triangle linkage that this file generates (2D hist and 2x 1D hist for each):

  1. no boundary, no fixing of trivial dofs
  2. boundary, nofixing of trivial dofs
  3. no boundary, fixed exterior face
  4. no boundary, fixed interior face
  5. no boundary, fixed center of mass
  6. no boundary, fixed center of mass and rotation
  7. boundary, fixed center of mass and rotation

In [1]:
%matplotlib inline

In [2]:
import datetime
dts = str(datetime.datetime.now())
date_time_str = dts[:10] + "-" + dts[11:13] + "-" + dts[14:16]
print date_time_str


2015-03-31-20-37

In [3]:
import numpy as np

import matplotlib.pyplot as plt

import bga_4_0 as bga
import manifold_reflected_brownian_motion as mrbm

import os

bga = reload(bga)
mrbm = reload(mrbm)

In [4]:
save_images = True

from matplotlib import rc
rc('font', **{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)

fig_width = 10
fig_height = 6
my_figsize = (fig_width, fig_height)
fig_dpi = 200
my_dpi = fig_dpi

In [5]:
manifold_name = 'building_game'
poly_name = 'octahedron'
int_num = 3

unary_boundary_name = 'self_intersection'
binary_boundary_name = 'dihedrals'

stat_name = 'test_2'

In [6]:
manifold_kwargs_simple = {'poly_name': poly_name, 
                          'int_num': int_num}
manifold_kwargs_ffaceint = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_face': 0}
manifold_kwargs_ffaceext = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_face': 1}
manifold_kwargs_com = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_com': True}
manifold_kwargs_comrot = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_com': True,
                          'fixed_rotation': True}

In [7]:
unary_boundary_kwargs = {'poly_name': poly_name, 'int_num': int_num}
binary_boundary_kwargs = {'poly_name': poly_name, 'int_num': int_num}

In [8]:
stat_kwargs = {}

In [9]:
err_tol = 10**-12
h = 0.05
N = 2*10**7

hist_min = 0.0
hist_max = 2.0*np.pi
hist_bins = 1000

In [10]:
kwargs_1  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_simple,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [11]:
kwargs_2  = {'manifold_name': manifold_name,  
             'unary_boundary_name': unary_boundary_name,
             'binary_boundary_name': binary_boundary_name,
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_simple,
             'unary_boundary_kwargs': unary_boundary_kwargs,
             'binary_boundary_kwargs': binary_boundary_kwargs,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [12]:
kwargs_3  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_ffaceext,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [13]:
kwargs_4  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_ffaceint,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [14]:
kwargs_5  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_com,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [15]:
kwargs_6  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_comrot,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [16]:
kwargs_7  = {'manifold_name': manifold_name,  
             'unary_boundary_name': unary_boundary_name,
             'binary_boundary_name': binary_boundary_name,
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_comrot,
             'unary_boundary_kwargs': unary_boundary_kwargs,
             'binary_boundary_kwargs': binary_boundary_kwargs,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [17]:
x0, links, lengths, faces = bga.load_bg_int(poly_name, int_num)

In [18]:
filename = lambda n: "T3_" + str(n) + ".pkl"

In [19]:
a = 0.5/np.pi
b = -a*0.1
c = -a*0.1
a2 = a
b2 = 0.028
x_range = np.linspace(0.0, 2.0*np.pi)
ys = a + b*np.cos(x_range) + c*np.cos(2*x_range)
ys2 = a2 + b2*np.cos(x_range)

In [20]:
if os.path.isfile(filename(1)):
    print "Reading z_1 from file..."
    z_1 = mrbm.MRBM.load(filename(1))
else:
    print "Generating z_1 samples..."
    z_1 = mrbm.MRBM(x0, h, **kwargs_1)
    s_1 = z_1.sample(N=N, record_trace=False, record_stats=True)
    z_1.dump(filename(1))


Generating z_1 samples...

In [21]:
xx1 = plt.hist(z_1.hist.midpoints, weights=z_1.hist.hist[0,:], normed=True, bins=40)
yy1 = plt.plot(x_range, ys, 'r')



In [22]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_1.stat_log[:,0],
                  z_1.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.title("Dihedrals Angles in Linkage of Three Triangles")
plt.colorbar()
if save_images == True:
    plt.savefig('T3_1_2D.eps', dpi=my_dpi)



In [23]:
#hh2n

In [24]:
if os.path.isfile(filename(2)):
    print "Reading z_2 from file..."
    z_2 = mrbm.MRBM.load(filename(2))
else:
    print "Generating z_2 samples..."
    z_2 = mrbm.MRBM(x0, h, **kwargs_2)
    s_2 = z_2.sample(N=N, record_trace=False, record_stats=True)
    z_2.dump(filename(2))


Generating z_2 samples...

In [25]:
xx2 = plt.hist(z_2.hist.midpoints, weights=z_2.hist.hist[0,:], normed=True, bins=40)
yy2 = plt.plot(x_range, ys, 'r')



In [26]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_2.stat_log[:,0],
                  z_2.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.title("Dihedrals Angles in Linkage of Three Triangles with Boundaries")
plt.colorbar()
if save_images == True:
    plt.savefig('T3_2_2D.eps', dpi=my_dpi)



In [27]:
if os.path.isfile(filename(3)):
    print "Reading z_3 from file..."
    z_3 = mrbm.MRBM.load(filename(3))
else:
    print "Generating z_3 samples..."
    z_3 = mrbm.MRBM(x0, h, **kwargs_3)
    s_3 = z_3.sample(N=N, record_trace=False, record_stats=True)
    z_3.dump(filename(3))


Reading z_3 from file...

In [27]:


In [28]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_3.stat_log[:,0],
                  z_3.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.title("Dihedrals Angles in Linkage of Three Triangles with Exterior Face Fixed")
plt.colorbar()
if save_images == True:
    plt.savefig('T3_3_2D.eps', dpi=my_dpi)



In [29]:
if os.path.isfile(filename(4)):
    print "Reading z_4 from file..."
    z_4 = mrbm.MRBM.load(filename(4))
else:
    print "Generating z_4 samples..."
    z_4 = mrbm.MRBM(x0, h, **kwargs_4)
    s_4 = z_4.sample(N=N, record_trace=False, record_stats=True)
    z_4.dump(filename(4))


Reading z_4 from file...

In [30]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_4.stat_log[:,0],
                  z_4.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.title("Dihedrals Angles in Linkage of Three Triangles with Interior Face Fixed")
plt.colorbar()
if save_images == True:
    plt.savefig('T3_4_2D.eps', dpi=my_dpi)



In [31]:
if os.path.isfile(filename(5)):
    print "Reading z_5 from file..."
    z_5 = mrbm.MRBM.load(filename(5))
else:
    print "Generating z_5 samples..."
    z_5 = mrbm.MRBM(x0, h, **kwargs_5)
    s_5 = z_5.sample(N=N, record_trace=False, record_stats=True)
    z_5.dump(filename(5))


Reading z_5 from file...

In [32]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_5.stat_log[:,0],
                  z_5.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.title("Dihedrals Angles in Linkage of Three Triangles with Center of Mass Fixed")
plt.colorbar()
if save_images == True:
    plt.savefig('T3_5_2D.eps', dpi=my_dpi)



In [33]:
if os.path.isfile(filename(6)):
    print "Reading z_6 from file..."
    z_6 = mrbm.MRBM.load(filename(6))
else:
    print "Generating z_6 samples..."
    z_6 = mrbm.MRBM(x0, h, **kwargs_6)
    s_6 = z_6.sample(N=N, record_trace=False, record_stats=True)
    z_6.dump(filename(6))


Reading z_6 from file...

In [34]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_6.stat_log[:,0],
                  z_6.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.title("Dihedrals Angles in Linkage of Three Triangles with Center of Mass and Rotations Fixed")
plt.colorbar()
if save_images == True:
    plt.savefig('T3_6_2D.eps', dpi=my_dpi)



In [35]:
if os.path.isfile(filename(7)):
    print "Reading z_7 from file..."
    z_7 = mrbm.MRBM.load(filename(7))
else:
    print "Generating z_7 samples..."
    z_7 = mrbm.MRBM(x0, h, **kwargs_7)
    s_7 = z_7.sample(N=N, record_trace=False, record_stats=True)
    z_7.dump(filename(7))


Reading z_7 from file...

In [36]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
hh2n = plt.hist2d(z_7.stat_log[:,0],
                  z_7.stat_log[:,1],
                  bins=100, 
                  normed=True,
                  vmin=0.0,
                  vmax=0.05)
plt.colorbar()
plt.title("Dihedrals Angles in Linkage of Three Triangles with Center of Mass and Rotations Fixing and Boundaries")
if save_images == True:
    plt.savefig('T3_7_2D.eps', dpi=my_dpi)